//
//  loginViewController.m
//  A段项目音乐播放
//
//  Created by dllo on 15/5/22.
//  Copyright (c) 2015年 lanou3g.com蓝鸥科技. All rights reserved.
//

#import "loginViewController.h"
#import "ThemeViewController.h"


@interface loginViewController ()
@property (nonatomic,retain)UIImageView *image;

@end

@implementation loginViewController

- (void)dealloc
{
    [super dealloc];
}

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.navigationController.navigationBar.translucent = YES;
        self.state = SwitchEnumNo;
        UIImage *aimage = [UIImage imageNamed:@"97.jpg"];
        self.image = [[UIImageView alloc]initWithImage:aimage];
        [self.image setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
        [self.view addSubview:self.image];
        [self.image release];
    }
    return self;
}

- (void)loadView
{
    [super loadView];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor clearColor];
    self.image.userInteractionEnabled = YES;
    [self create];
    
}


- (void)create
{
    
    UIImageView *viewHead = [[UIImageView alloc]initWithFrame:CGRectMake(60, 70, 150, 150)];
    viewHead.userInteractionEnabled = YES;
    viewHead.image = [UIImage imageNamed:@"100.jpg"];
    [viewHead.layer setCornerRadius:75];
    [viewHead.layer setMasksToBounds:YES];
    [self.image addSubview:viewHead];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(touchImage:)];
    [viewHead addGestureRecognizer:tap];
    [tap release];
    
    UIButton *buttonBright = [[UIButton alloc]initWithFrame:CGRectMake(20, 300, 150, 35)];
    [buttonBright setTitle:@"亮度" forState:UIControlStateNormal];
    [buttonBright setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [buttonBright setBackgroundColor:[UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.1]];
    [buttonBright addTarget:self action:@selector(buttonBright:) forControlEvents:UIControlEventTouchUpInside];
    [self.image addSubview:buttonBright];
    
    
    UIButton *buttonSetting = [[UIButton alloc]initWithFrame:CGRectMake(200, 300, 150, 35)];
    [buttonSetting setTitle:@"设置" forState:UIControlStateNormal];
    [buttonSetting setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [buttonSetting setBackgroundColor:[UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.1]];
    [buttonSetting addTarget:self action:@selector(buttonSetting:) forControlEvents:UIControlEventTouchUpInside];
    [self.image addSubview:buttonSetting];
    
    
//    UIButton *buttonLogin = [[UIButton alloc]initWithFrame:CGRectMake(20, 350, 150, 35)];
//    [buttonLogin setTitle:@"登录" forState:UIControlStateNormal];
//    [buttonLogin setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [buttonLogin setBackgroundColor:[UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.1]];
//    [buttonLogin addTarget:self action:@selector(buttonLogin:) forControlEvents:UIControlEventTouchUpInside];
//    [self.image addSubview:buttonLogin];
    
    
    UIButton *buttonTheme = [[UIButton alloc]initWithFrame:CGRectMake(200, 350, 150, 35)];
    [buttonTheme setTitle:@"主题背景" forState:UIControlStateNormal];
    [buttonTheme setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [buttonTheme setBackgroundColor:[UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.1]];
    [buttonTheme addTarget:self action:@selector(buttonTheme:) forControlEvents:UIControlEventTouchUpInside];
    [self.image addSubview:buttonTheme];
    
    UIButton *buttonSleep = [[UIButton alloc]initWithFrame:CGRectMake(20, 400, 150, 35)];
    [buttonSleep setTitle:@"睡眠" forState:UIControlStateNormal];
    [buttonSleep setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [buttonSleep setBackgroundColor:[UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.1]];
    [buttonSleep addTarget:self action:@selector(buttonSleep:) forControlEvents:UIControlEventTouchUpInside];
    [self.image addSubview:buttonSleep];
    
//    UIButton *buttonAbout = [[UIButton alloc]initWithFrame:CGRectMake(200, 400, 150, 35)];
//    [buttonAbout setTitle:@"关于我们" forState:UIControlStateNormal];
//    [buttonAbout setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [buttonAbout setBackgroundColor:[UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.1]];
//    [buttonAbout addTarget:self action:@selector(buttonAbout:) forControlEvents:UIControlEventTouchUpInside];
//    [self.image addSubview:buttonAbout];
    
    
    UIButton *buttonExit = [[UIButton alloc]initWithFrame:CGRectMake(20, 450, 320, 35)];
    [buttonExit setTitle:@"退出" forState:UIControlStateNormal];
    [buttonExit setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [buttonExit setBackgroundColor:[UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.1]];
    [buttonExit addTarget:self action:@selector(buttonExit:) forControlEvents:UIControlEventTouchUpInside];
    [self.image addSubview:buttonExit];
    
    UISwitch *sw = [[UISwitch alloc]initWithFrame:CGRectMake(20, 450, 320, 35)];
    
    
}

// 点击图片
- (void)touchImage:(UITapGestureRecognizer *)tap
{
    
}

// 亮度 按钮的点击事件
- (void)buttonBright:(id)sender
{
    if (self.state == SwitchEnumNo ) {
        self.slider = [[UISlider alloc]initWithFrame:CGRectMake(50, 500, 300, 10)];
        _slider.minimumValue = 0;
        _slider.maximumValue = 255;
        [self.view addSubview:_slider];
        [_slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
        self.state = SwitchEnumYes;
    } else if (self.state == SwitchEnumYes)
    {
        [self.slider removeFromSuperview];
        self.state = SwitchEnumNo;
    }
    
}

// 点击空白处 收回亮度条
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self.slider removeFromSuperview];
    self.state = SwitchEnumNo;
}


// 设置按钮的点击事件
- (void)buttonSetting:(id)sender
{
    
}


// 主题背景 按钮的点击事件
- (void)buttonTheme:(id)sender
{
    ThemeViewController *theme = [[ThemeViewController alloc]init];
    [self.navigationController pushViewController:theme animated:YES];
    
}

// 睡眠 按钮的点击事件
- (void)buttonSleep:(id)sender
{
    UIView *sleepView = [[UIView alloc]initWithFrame:CGRectMake(80, 100, 200, 350)];
    [self.view addSubview:sleepView];
    [sleepView setBackgroundColor:[UIColor redColor]];
    [self.view bringSubviewToFront:sleepView];
    //    [self.view sendSubviewToBack:sleepView];
    self.view.alpha = 0.5;
    
    
    UITableView *table = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, sleepView.frame.size.width, sleepView.frame.size.height) style:UITableViewStylePlain];
    [sleepView addSubview:table];
    
}




//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//{
//    return  7;
//}
//
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    if (indexPath.row == 0) {
//        return 60;
//    }else{
//        return 40;
//    }
//}
//
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//
//}


- (void)buttonExit:(id)sender
{
    
}

// 滑条的 点击事件
- (void)sliderAction:(UISlider *)slider
{
    self.view.backgroundColor = [UIColor colorWithRed:slider.value/25 green:slider.value/255 blue:slider.value/255 alpha:0.5];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
